package com.iot.modbus.route;

import com.iot.modbus.manager.ReaderSessionManager;
import com.iot.modbus.route.impl.SimpleReaderSessionRoute;
import com.serotonin.modbus4j.ip.IpParameters;

import java.nio.ByteOrder;

public class ReaderRoute {
    private static final ReaderSessionRoute route = new SimpleReaderSessionRoute();

    public static boolean readBoolean16(IpParameters ipParameters, int startOffset, ByteOrder byteOrder, int bit) {
        return route.readBoolean16(ipParameters, startOffset, byteOrder, bit);
    }

    public static short[] read(IpParameters ipParameters, int startOffset, int numberOfRegisters) {
        return route.read(ipParameters, startOffset, numberOfRegisters);
    }

    public static Short readInt16(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return route.readInt16(ipParameters, startOffset, byteOrder);
    }


    public Integer readUInt16(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return ReaderSessionManager.get(ipParameters).readUInt16(startOffset,byteOrder);
    }


    public static Integer readInt32(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return route.readInt32(ipParameters, startOffset, byteOrder);
    }


    public static Long readUInt32(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return route.readUInt32(ipParameters, startOffset, byteOrder);
    }


    public static Long readInt64(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return route.readInt64(ipParameters, startOffset, byteOrder);
    }

    public static Float readFloat32(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return route.readFloat32(ipParameters, startOffset, byteOrder);
    }

    public Double readFloat64(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return route.readFloat64(ipParameters, startOffset, byteOrder);
    }
}
